<template>
  <div class="xz-echarts-twoone" :id="name"></div>
</template>

<script>
import echarts from "echarts";
export default {
  data() {
    return {
      name: "cw-twoone"
    };
  },
  created() {
    this.$nextTick(function() {
      this.drow(this.name);
    });
  },
  methods: {
   drow(id) {
      this.charts = echarts.init(document.getElementById(id));
      this.charts.setOption({
        title: {
          text: "采购农具金额",
          left: "center",
          textStyle: {
            color: "rgb(255, 255, 255)",
            fontSize: 18
          }
        },
        tooltip: {
          trigger: "item",
          formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
          // orient: 'vertical',
          // top: 'middle',
          bottom: 10,
          left: "center",
          data: ["喷雾机", "施肥机", "饲料机", "灌溉机", "消毒机", "耕耘机"],
          textStyle: {
            color: "rgb(255, 255, 255)"
          }
        },
         color: [
          "rgb(214, 81, 255)",
          "#1e90ff",
          "rgb(255, 212, 0)",
          "#b8860b",
          "#32cd32",
          "#7b68ee",
          "#ff69b4"
        ],
        series: [
          {
            type: "pie",
            radius: "65%",
            center: ["50%", "50%"],
            selectedMode: "single",
            data: [
               {
                value: 150,
                name: "喷雾机"
              },
              {
                value: 30,
                name: "施肥机"
              },
              {
                value: 80,
                name: "饲料机"
              },
              {
                value: 60,
                name: "灌溉机"
              },
              {
                value: 100,
                name: "消毒机"
              },
              {
                value: 120,
                name: "耕耘机"
              }
            ],
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: "rgba(255, 0, 0, 0.1)"
              }
            }
          }
        ]
      });
    }
  }
};
</script>

<style lang="scss">
// 需要修改 .xz-echarts-xx
.xz-echarts-twoone {
  height: 400px;
  width: 100%;
}
</style>
